<template>
  <el-input
    v-model.trim="input"
    placeholder="请输入搜索内容"
    class="search-input"
    @keydown.enter="handleSearch(input)"
  />
</template>

<script setup>
import { ref } from 'vue'
import { useMapgisStore } from '@/stores/mapgis'

const $store = useMapgisStore()
const input = ref('')
const handleSearch = (value) => {
  if (value === '') {
    ElMessage.error('请输入搜索内容')
    return
  }
 
  $store.queryBySearch(value)
  input.value = ''
}
</script>

<style scoped>
.search-input {
  width: 240px;
  height: 32px;
  margin: auto 0;
}
</style>
